package jp.cane.delicious.recipe10;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.widget.Toast;

public class MainService extends Service {
	private Thread thread = null;

	private Handler handler = new Handler();

	@Override
	public void onStart(Intent intent, int startId) {
		Toast.makeText(this, "Service has been started.", Toast.LENGTH_SHORT)
				.show();

		this.thread = new Thread() {
			public void run() {
				try {
					while (true) {
						Thread.sleep(10 * 1000);
						MainService.this.handler.post(new Runnable() {
							public void run() {
								Toast.makeText(MainService.this, "Hello!",
										Toast.LENGTH_SHORT).show();
							}
						});
					}
				} catch (InterruptedException e) {
				}
			}
		};
		this.thread.start();
	}

	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}

}
